{include file="public_head" /}

<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- chk_3 -->
<link href="/static/console/css/chk_3.css" rel="stylesheet" type="text/css"/>

<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">
                        <h3>订单详细管理</h3>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>查看订单
                                    <!--<small>different form elements</small>-->
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>

                            <div class="x_content">
                                <div id="printArea">
                                    <style>
                                        .form-group{margin-bottom:0}
                                        .form-horizontal .control-labe {padding-top: 0}
                                    </style>
                                    <br/>
                                    <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                          method="post" id="registerForm">

                                        <div class="form-group tc">
                                            <label class="control-label col-md-3" style="">订 单 号</label>
                                            <div class="col-md-2" style="margin-top: 10px;">
                                                <div>{$item.order_number}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">买家账号：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{$item.username}&nbsp{$item.car_number}</div>
                                            </div>
                                        </div>

                                        {notempty name="gift_card"}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">会员卡：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>卡号:{$gift_card.card_num} 激活码：{$gift_card.card_password}</div>
                                            </div>
                                        </div>
                                        {/notempty}

                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">门店名称：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                {if condition="(session('role_id') eq 1 || session('role_id') eq 2 ) && session('auding_status') eq 2"}
                                                <select onChange="update_order_shop()" name="shop_id" class="form-control" style="width: 300px;float: left;" tabindex="-1">
                                                <option value="0">请选择门店</option>
                                                {foreach :model('shop')->where('auding_status',2)->order('shop_status','asc')->select() as $key=>$vo }
                                                <option value="{$vo.id}" {eq name='$item.shop_id|default=""' value='$vo.id' }selected{/eq}>
                                                {$vo.shop_title}
                                                </option>
                                                {/foreach}
                                                </select>
                                                {else/}
                                                {$item.shop_title}
                                                {/if}
                                            </div>
                                        </div>

                                        <script>
                                            function update_order_shop() {
                                                var id = "{:input('id')}";
                                                var shop_id = $('[name="shop_id"]').val();
                                                $.ajax({
                                                    url : '{:url("order/update_shop_id")}',
                                                    data:{'id':id,'shop_id':shop_id},
                                                    dataType:'html',
                                                    success:function(data){
                                                        data = JSON.parse(data);
                                                        console.log(data)
                                                        if(data.code == 200){
                                                            layer.msg('门店修改成功');
                                                        }else{
                                                            layer.msg(data.message);
                                                        }
                                                    }
                                                });
                                            }

                                        </script>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 ">车牌号：</label>
                                            <div class="col-md-6 " style="margin-top: 10px;">

                                                <input type="text" style="float: left; height: 34px; margin-right: 10px;" name="car_number" value="{$item.car_number}"
                                                {if condition="session('role_id') neq 1"}
                                                {if condition="strpos($item.car_number,'-') === false && $item.car_number neq ''"}
                                                       readonly
                                                {/if}
                                                {/if}
                                                />
                                                {empty name="$item.car_number"}<a  class="btn btn-primary" onClick="car_number(this)">修改</a>{/empty}
                                                {if condition="session('role_id') eq 1"}
                                                {notempty name="$item.car_number"}<a  class="btn btn-primary" onClick="car_number2(this)">确认车牌</a>{/notempty}
                                                {else/}
                                                {if condition="strpos($item.car_number,'-') !== false"}<a  class="btn btn-primary" onClick="car_number2(this)">确认车牌</a>{/if}
                                                {/if}

                                            </div>
                                        </div>
                                        <!--<div class="form-group tc">
                                            <label class="control-label col-md-3 ">车型：</label>
                                            <div class="col-md-6 " style="margin-top: 10px;">
                                                <input type="text" style="float: left; height: 34px; margin-right: 10px;" name="chexing" value="{$item.chexing}">
                                            </div>
                                        </div>-->
                                        <script>
                                            function car_number(t) {
                                                var member_id = "{$item.member_id}";

                                                var v = $(t).prev().val();
                                                var order_id = "{:input('id')}";
                                                $.ajax({
                                                    type: "POST",
                                                    url: "{:url('member/car_number')}",
                                                    data: {id:member_id,car_number:v,order_id:order_id},
                                                    dataType: "json",
                                                    success: function(ret){
                                                        //ret == true == 1/*?*/
                                                        if(ret == true){
                                                            layer.msg(ret.message);
                                                            history.go(0);
                                                        }
                                                        else{
                                                            layer.msg(ret.message);
                                                            history.go(0);
                                                        }
                                                    }

                                                });
                                            }
                                            function car_number2(t) {
                                                var member_id = "{$item.member_id}";
                                                var v = $(t).prev().val();
                                                var order_id = "{:input('id')}";
                                                $.ajax({
                                                    type: "POST",
                                                    url: "{:url('member/car_number2')}",
                                                    data: {id:member_id,car_number:v,order_id:order_id},
                                                    dataType: "json",
                                                    success: function(ret){
                                                        //ret == true == 1/*?*/
                                                        if(ret == true){
                                                            layer.msg(ret.message);
                                                            history.go(0);
                                                        }
                                                        else{
                                                            layer.msg(ret.message);
                                                            history.go(0);
                                                        }
                                                    }

                                                });
                                            }
                                        </script>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 ">车型：</label>
                                            <div class="col-md-6 " style="margin-top: 10px;">
                                                <div>{$item.car_model}</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 ">是否认证：</label>
                                            <div class="col-md-6 " style="margin-top: 10px;">
                                                <div>{switch name="$item.is_certification"}{case 1}未认证{/case}{case 3}等待认证{/case}{case 2}已认证{/case}{/switch}</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3  ">绩效订单：</label>
                                            <div class="col-md-6 " style="margin-top: 10px;">
                                                <div>
                                                    {switch name="item.finance_order"}
                                                    {case 1}业务员订单{/case}
                                                    {case 2}二维码订单{/case}
                                                    {case 3}门店订单{/case}
                                                    {case 4}普通订单{/case}
                                                    {default /}-
                                                    {/switch}
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3  ">(线上/下)订单：</label>
                                            <div class="col-md-6 " style="margin-top: 10px;">
                                                <div>
                                                    {switch name="item.order_online"}
                                                    {case 1}线上订单{/case}
                                                    {case 2}线下订单{/case}
                                                    {default /}-
                                                    {/switch}
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 ">下单/退款时间：</label>
                                            <div class="col-md-6 " style="margin-top: 10px;">
                                                <div>{$item.create_time}{in name="$item.status" value="10,11,12"} / {$item.refund_create_time}{/in}</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 ">总金额：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{$item.amount}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 ">礼包金额：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{$item.sale_price}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="control-label col-md-3 ">优惠券使用情况：</label>
                                            <div class="col-md-4">
                                                {if condition="$item.coupon_id gt 0"}
                                                <div style="margin-top: 8px;"> ID:{$item.coupon_id} 标题 : {$item.coupon_title}-满 : {$item.coupon_totol_price} 元 - {$item.coupon_price} 元</div>
                                                {elseif condition="$item.coupon_id eq 0 && $item.status eq 1 && $item.amount gt 0" /}
                                                <select {if condition="session('role_id') neq 1"} {/if} onChange="use_coupon({$item.id},this.value,{$item.member_id})" name="shop_id123" class="select2_single form-control" style="width: 440px;float: left;" tabindex="-1">
                                                    <option value="0">请选择优惠券</option>
                                                    {volist name="member_coupon" id="vo"}
                                                    <option value="{$vo.id}" >{$vo.title}-满{$vo.total_price}元减{$vo.minus_price}元</option>
                                                    {/volist}
                                                </select>
                                                {/if}
                                            </div>
                                        </div>
                                        <script>
                                            function use_coupon(order_id,member_coupon_id,member_id) {

                                                if(member_coupon_id > 0){
                                                    $.ajax({
                                                        type: "POST",
                                                        url: "{:url('service_order/use_coupon_service')}",
                                                        data: {order_id:order_id,member_coupon_id:member_coupon_id,member_id:member_id},
                                                        dataType: "json",
                                                        success: function(ret){
                                                            //ret == true == 1/*?*/
                                                            if(ret.code == 200){
                                                                console.log(ret);
                                                                layer.msg('使用成功');
                                                                history.go(0);
                                                            }
                                                            else{
//                                                            layer.msg('失败');
//                                                            history.go(0);
                                                            }
                                                        }

                                                    });
                                                }else{
                                                    alert('失败');
                                                }
                                            }
                                        </script>
                                        {in name="$item.status" value="10,11,12"}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 ">退款金额：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{$refund.amount}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">退款理由：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{$refund.title}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">退款说明：</label>
                                            <div class="col-md-6 " style="margin-top: 10px;">
                                                <div>{$refund.explain}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        {/in}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">买家留言：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{$item.explain}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">支付方式：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{switch name="item.order_online"}{case 1}线上{/case}{case 2}线下{/case}{/switch}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">支付类型：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{switch name="item.pay_type"}{case 1}微信{/case}{case 2}支付宝{/case}{default /}-{/switch}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                            </div>
                                        </div>
                                        {eq name="$item.t_type" value="1"}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">礼包标题：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                <div>{$item.gift_title}</div>
                                            </div>
                                        </div>

                                        <!--<div class="form-group tc">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">到期时间：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">-->
                                        <!--<div>{$item.use_time}&nbsp;&nbsp;&nbsp;&nbsp;使用期限({$item.day})天</div>-->
                                        <!--</div>-->
                                        <!--</div>-->

                                        <div class="form-group">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">礼包详情：</label>
                                            <div class="col-md-7 col-sm-6 col-xs-12" style="margin-top: 10px; width:70%">
                                                <table width="100%" border="1" style="font-family: '微软雅黑';">
                                                    <tr align="center" style="font-size: 16px;">
                                                        <td width="160">服务分类</td>
                                                        <td width="160">服务内容</td>
                                                        <td width="90">总次数(剩余次数)</td>
                                                        <td width="90">服务期限</td>
                                                        <td width="90">结束时间</td>

                                                    </tr>
                                                    {volist name='order_gift_count' id='vo'}
                                                    <tr align="center">
                                                        <td>{$vo.cat_name|default=''}</td>
                                                        <td>{$vo.cat_name2|default=''}</td>
                                                        <td>{$vo.gift_origin_count|default=''}({$vo.gift_count|default=''})</td>
                                                        <td>{$vo.day}(天)</td>
                                                        <td>{$vo.end_time}</td>
                                                    </tr>
                                                    {/volist}
                                                </table>
                                            </div>
                                        </div>

                                        <div class="form-group service_people">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">服务人员与提成：</label>
                                            <div class="col-md-7 col-sm-7 col-xs-12" style="margin-top: 10px; width:70%">
                                                <table width="100%" border="1" style="font-family: '微软雅黑';">
                                                    <tr align="center" style="font-size: 16px;">
                                                        <td width="160">服务门店</td>
                                                        <td width="70">服务人员</td>
                                                        <td width="70">服务分类</td>
                                                        <td width="150">服务内容</td>
                                                        <td width="70">提成金额</td>
                                                        <td width="150">消费日期</td>
                                                        <td width="150">用户是否确认使用</td>
                                                        <td width="50">人员是否确认</td>
                                                        <td width="50">岗位</td>
                                                        <td>批次</td>
                                                        {eq name=":session('auding_status')" value="2"}
                                                        
                                                        <td>操作</td>
                                                        {/eq}
                                                    </tr>
                                                    {volist name='gift_assignor_records' id='vo'}
                                                    <tr align="center">
                                                        <td>{$vo.shop_title|default=''}</td>
                                                        <td>{$vo.name|default=''}</td>
                                                        <td>{$vo.cat_name|default=''}</td>
                                                        <td>{$vo.assignor_content|default=''}</td>
                                                        <td>{$vo.assignor_price|default=''}</td>
                                                        <td>{$vo.create_time|default=''}</td>
                                                        <td>
                                                            {switch name="$vo.is_agree"}
                                                            {case 1}未确认{/case}
                                                            {case 2}已确认{/case}
                                                            {/switch}
                                                        </td>
                                                        <td>
                                                            {switch name="$vo.is_assignor_agree"}
                                                            {case 1}未确认{/case}
                                                            {case 2}已确认{/case}
                                                            {/switch}
                                                        </td>
                                                        <td>{$vo.title|default=''}</td>
                                                        <td>{$vo.pici|default=''}</td>
                                                        {eq name=":session('auding_status')" value="2"}
                                                        
                                                        <td class="click3" onClick="del({$vo.id})">删除</td>
                                                        {/eq}
                                                    </tr>
                                                    {/volist}
                                                </table>
                                            </div>
                                        </div>

                                        {eq name=":session('auding_status')" value="1"}
                                        <div class="form-group service_people tc" >
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">服务人员提成：</label>
                                            <div class="col-md-6 col-sm-6 col-xs-12">
                                                <table class="table table-striped table-bordered table-hover">
                                                    <thead>
                                                    <th>服务人员</th>
                                                    <th>服务分类</th>
                                                    <th>服务内容</th>
                                                    <th>服务金额</th>
                                                    <th>操作</th>
                                                    <th>岗位</th>
                                                    <th>批次</th>
                                                    </thead>
                                                    <tbody id="fieldtr">

                                                    <tbody align="right">
                                                    <tr>
                                                        <td colspan="7"><a href="javascript:;" class="addNewTr click3" title="新增一条">1新增一条</a></td>
                                                    </tr>
                                                    </tbody>

                                                </table>
                                            </div>
                                        </div>
                                        {eq name="$item.order_online" value="2"}
                                        <div class="form-group service_people tc" >
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">礼包销售提成：</label>
                                            <div class="col-md-6 col-sm-6 col-xs-12">
                                                <table class="table table-striped table-bordered table-hover">
                                                    <thead>
                                                    <th>服务人员</th>
                                                    <th>服务分类</th>
                                                    <th>服务内容</th>
                                                    <th>服务金额</th>
                                                    <th>操作</th>
                                                    <th>岗位</th>
                                                    <th>批次</th>
                                                    </thead>
                                                    <tbody id="fieldtr_shop">

                                                    <tbody align="right">
                                                    <tr>
                                                        <td colspan="7"><a href="javascript:;" class="addNewTr_shop click3" title="新增一条">2新增一条</a></td>
                                                    </tr>
                                                    </tbody>

                                                </table>
                                            </div>
                                        </div>
                                        {/eq}
                                        {/eq}
                                        {eq name=":session('auding_status')" value="2"}
                                        <div class="form-group service_people tc" id="service_people">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">服务人员提成：</label>
                                            <div class="col-md-7 col-sm-6 col-xs-12" style="width:70%">
                                                <table class="table table-striped table-bordered table-hover">
                                                    <thead>
                                                    <th>服务门店</th>
                                                    <th>服务人员</th>
                                                    <th>服务分类</th>
                                                    <th>服务内容</th>
                                                    <th>服务金额</th>
                                                    <th>操作</th>
                                                    <th>岗位</th>
                                                    <th>批次</th>
                                                    </thead>
                                                    <tbody id="fieldtr">

                                                    <tbody align="right">
                                                    <tr>
                                                        <td colspan="8"><a href="javascript:;"  class="addNewTrshop click3" title="新增一条">3新增一条</a></td>
                                                    </tr>
                                                    </tbody>

                                                </table>
                                            </div>
                                        </div>
                                        {eq name="$item.order_online" value="2"}
                                        <div class="form-group service_people tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">礼包销售提成：</label>
                                            <div class="col-md-7 col-sm-6 col-xs-12" style="width:70%">
                                                <table class="table table-striped table-bordered table-hover">
                                                    <thead>
                                                    <th>销售门店</th>
                                                    <th>销售人员</th>
                                                    <th>销售分类</th>
                                                    <th>销售内容</th>
                                                    <th>销售金额</th>
                                                    <th>操作</th>
                                                    <th>岗位</th>
                                                    <th>批次</th>
                                                    </thead>
                                                    <tbody id="fieldtr_backstage">

                                                    <tbody align="right">
                                                    <tr>
                                                        <td colspan="8"><a href="javascript:;"  class="addNewTrshop_backstage " title="新增一条">4新增一条</a></td>
                                                    </tr>
                                                    </tbody>

                                                </table>
                                            </div>
                                        </div>
                                        {/eq}
                                        {/eq}
                                        <div class="form-group service_people tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">商品记录：</label>
                                            <div class="col-md-8 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <table width="100%" border="1" style="font-family: '微软雅黑';">
                                                    <tr align="center" style="font-size: 16px;">
                                                        <td >服务门店</td>
                                                        <td>商品规格</td>
                                                        <td >数量</td>
                                                        <td >消费日期</td>
                                                        {eq name=":session('auding_status')" value="2"}
                                                        <td>操作</td>
                                                        {/eq}
                                                    </tr>
                                                    {volist name='service_order_goods' id='vo'}
                                                    <tr align="center">
                                                        <td>{$vo.shop_title|default=''}</td>
                                                        <td>{$vo.spec_id}-{$vo.title|default=''}-{$vo.attribute|default=''}</td>
                                                        <td>{$vo.number|default=''}</td>
                                                        <td>{$vo.create_time|default=''}</td>
                                                        {eq name=":session('auding_status')" value="2"}
                                                        <td onClick="del({$vo.id})" class="click3">删除</td>
                                                        {/eq}
                                                    </tr>
                                                    {/volist}
                                                </table>
                                            </div>
                                        </div>
                                        {if condition="strtotime($item.use_time) gt time()" }
                                        <div class="form-group tc" id="service_people">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">商品添加：</label>
                                            <div class="col-md-8 col-sm-6 col-xs-12">
                                                <table class="table table-striped table-bordered table-hover">
                                                    <thead>
                                                    <th>商品分类</th>
                                                    <th>商品规格</th>
                                                    <th>商品数量</th>
                                                    <th>创建时间</th>
                                                    <th>操作</th>
                                                    </thead>
                                                    <tbody id="fieldtrgoods">

                                                    </tbody>
                                                    <tbody align="right">
                                                    <tr>
                                                        <td colspan="6"><a href="javascript:;" class="addNewTrgoods" title="新增一条" >5新增一条</a></td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                        {/if}
                                        {else/}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">会员卡类型：</label>
                                            <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <div>{switch name="$item.mc_type"}{case 1}年卡- {/case}{case 2}次卡{/case}{/switch}</div>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">会员卡标题：</label>
                                            <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <div>{$item.mc_title}</div>
                                            </div>
                                        </div>
                                        <!--<div class="form-group tc">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">会员卡有效时间：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">-->
                                        <!--<div>{:substr($item.mc_start_time,0,10)} / {:substr($item.mc_end_time,0,10)}</div>-->
                                        <!--</div>-->
                                        <!--</div>-->
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">会员卡图片：</label>
                                            <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <div><img src="/{$item.mc_single_pic}" height="100"/></div>
                                            </div>
                                        </div>
                                        <div class="form-group service_people tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">会员卡详情：</label>
                                            <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <table width="100%" border="1" style="font-family: '微软雅黑';">
                                                    <tr align="center" style="font-size: 16px;">
                                                        <td width="160">服务分类</td>
                                                        <td width="160">服务内容</td>
                                                        <td width="90">礼包总次数(剩余次数)</td>
                                                    </tr>
                                                    {volist name='order_gift_count' id='vo'}
                                                    <tr align="center">
                                                        <td>{$vo.cat_name|default=''}</td>
                                                        <td>{$vo.cat_name2|default=''}</td>
                                                        <td>{$vo.gift_origin_count|default=''}({$vo.gift_count|default=''})</td>
                                                    </tr>
                                                    {/volist}
                                                </table>
                                            </div>
                                        </div>

                                        {/eq}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">订单状态：</label>
                                            <div class="col-md-1" style="margin-top: 10px;">
                                                {switch name="item.status"}
                                                {case 1}未支付{/case}
                                                {case 6}进行中{/case}
                                                {case 5}待评价{/case}
                                                {case 4}完成{/case}
                                                {case 10}退款中{/case}
                                                {case 11}退款成功{/case}
                                                {case 12}退款失败{/case}
                                                {case 20}已取消({$item.cancel_content}){/case}
                                                {/switch}
												{switch name="item.tui_status"}
													{case 2}<br>(之前退款过,<br>选择了退款失败){/case}
												{/switch}
                                                <br/>
                                                {if condition="$item.status eq 2"}
                                                <input type="checkbox" name="status"  value="3" datatype="*" nullmsg="请选择已发货！" > 已发货
                                                {/if}
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3">是否开发票：</label>
                                            <div class="col-md-6" style="margin-top: 10px;">
                                                {switch name="item.bill"}{case 1}开{/case}{case 2} 否{/case}{default /}{/switch}<br>
                                                {eq name="$item.bill" value="1"}
                                                发票类型：{switch name="item.bill_type"}{case 1}电子{/case}{case 2} 普通{/case}{case 3} 增值税{/case}{default /}{/switch}<br>
                                                发票抬头：{switch name="item.bill_header"}{case 1}个人{/case}{case 2} 单位{/case}{default /}{/switch}<br>
                                                发票内容：{$item.bill_content}<br>
                                                发票电话：{$item.bill_phone}<br>
                                                电子邮箱：{$item.bill_email}<br>
                                                {/eq}
                                            </div>
                                        </div>
                                        {in name="item.status" value="1,6,5,4"}
                                        <div class="form-group tc service_people">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12 ">备注信息：</label>
                                            <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <textarea type="text" placeholder="备注" style="width: 500px;height: 100px;" {neq name=":session('role_id')" value="1"}readonly{/neq}
                                                          class="form-control col-md-7 col-xs-12" name="explain">{$item.explain|default=''}</textarea>

                                            </div>
                                        </div>
                                        {/in}
                                        {if condition="$item.is_free_order eq 2"}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">免费订单审核：</label>
                                            <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <table class="table table-striped table-bordered table-hover">
                                                    <thead>
                                                    <tr><th>审核状态</th><th>一级审核</th><th>二级审核</th><th>三级审核</th></tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr>
                                                        <td class="td0">
                                                            {switch name="$item.auding_status"}
                                                            {case 1}等待审核{/case}
                                                            {case 2}审核成功{/case}
                                                            {case 3}审核失败{/case}
                                                            {/switch}
                                                        </td>
                                                        <td class="td1">
                                                            {switch name="$item.auding_status1"}
                                                            {case 1}等待审核{/case}
                                                            {case 2}审核成功{/case}
                                                            {case 3}审核失败{/case}
                                                            {/switch}
                                                        </td>
                                                        <td class="td2">
                                                            {switch name="$item.auding_status2"}
                                                            {case 1}等待审核{/case}
                                                            {case 2}审核成功{/case}
                                                            {case 3}审核失败{/case}
                                                            {/switch}
                                                        </td>
                                                        <td class="td3">
                                                            {switch name="$item.auding_status3"}
                                                            {case 1}等待审核{/case}
                                                            {case 2}审核成功{/case}
                                                            {case 3}审核失败{/case}
                                                            {/switch}
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td></td>
                                                        <td>
                                                            {if condition="(session('role_id') eq 1 || session('role_id') eq 2 || session('role_id') eq 11) && ($item.auding_status eq 1 || $item.auding_status eq 3)"}
                                                            <input type="checkbox" id="checkbox41_{$item.id}" class="chk_3"
                                                                   value="{$item.auding_status1}" {eq name="item['auding_status1']" value="2"}checked{/eq} />
                                                            <label style="margin-left: 30px;margin-top: 5px;"
                                                                   onclick="auding_order({$item['id']},'auding_status1')"
                                                                   for="checkbox41_{$item.id}"></label>
                                                            {/if}
                                                        </td>
                                                        <td>
                                                            {if condition="session('role_id') eq 12 && $item.auding_status1 eq 2 && ($item.auding_status eq 1 || $item.auding_status eq 3)"}
                                                            <input type="checkbox" id="checkbox42_{$item.id}" class="chk_3"
                                                                   value="{$item.auding_status2}" {eq name="item['auding_status2']" value="2"}checked{/eq} />
                                                            <label style="margin-left: 30px;margin-top: 5px;"
                                                                   onclick="auding_order({$item['id']},'auding_status2')"
                                                                   for="checkbox42_{$item.id}"></label>
                                                            {/if}
                                                        </td>
                                                        <td>
                                                            {if condition="session('role_id') eq 13 && $item.auding_status2 eq 2 && $item.auding_status1 eq 2 && $item.auding_status eq 1"}
                                                            <input type="checkbox" id="checkbox43_{$item.id}" class="chk_3"
                                                                   value="{$item.auding_status3}" {eq name="item['auding_status3']" value="2"}checked{/eq} />
                                                            <label style="margin-left: 30px;margin-top: 5px;"
                                                                   onclick="auding_order({$item['id']},'auding_status3')"
                                                                   for="checkbox43_{$item.id}"></label>
                                                            {/if}
                                                        </td>

                                                    </tr>
                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                        <script>
                                            function auding_order(id,auding_status){
                                                var reason = $('[name="reason"]').val();
                                                $.ajax({
                                                    type: "POST",
                                                    url: "{:url('order/auding_order')}",
                                                    data: {id:id,auding_status:auding_status,reason:reason},
                                                    dataType: "json",
                                                    success: function(ret){
                                                        //ret == true == 1/*?*/
                                                        if(ret == 2){
                                                            console.log(ret);
                                                            layer.msg('审核成功');
                                                            history.go(0);
                                                        }
                                                        else{
                                                            layer.msg('等待审核');
                                                            history.go(0);
                                                        }
                                                    }

                                                });
                                            }
                                        </script>
                                        {if condition="($item.auding_status eq 1 || $item.auding_status eq 3) || ((session('role_id') eq 1 || session('role_id') eq 2 || session('role_id') eq 11 || session('role_id') eq 12 || session('role_id') eq 13))"}
                                        <div class="form-group tc">
                                            <div class="form-group">
                                                <label class="control-label col-md-3 ">失败原因：</label>
                                                <div class="col-md-6 ">
                                                    <textarea name="reason" rows="5" style="width: 300px;">{$item.reason|default=''}</textarea>
                                                </div>
                                            </div>
                                        </div>
                                        {/if}
                                        {/if}
										{if $item.tui_status =='2'}
										<div class="form-group tc">
										    <label class="control-label col-md-3 col-sm-3 col-xs-12">退款审核记录：</label>
										    <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
										        <table width="80%" border="1" style="font-family: '微软雅黑';">
										            <tr align="center" style="font-size: 16px;">
										                <td>申请者</td>
										                <td>申请门店</td>
										                <td>审核状态</td>
										                <td>审核时间</td>
										                <td>失败原因</td>
										            </tr>
										            {volist name='refund_order_audit_records' id='goods_list'}
										            <tr align="center">
										                <td>{$goods_list.username|default=''}</td>
										                <td>{$goods_list.shop_title|default=''}</td>
										                <td>
										                    {switch name="$goods_list.status"}
										                    {case 11}审核成功{/case}
										                    {case 12}审核失败{/case}
										                    {/switch}
										                </td>
										                <td>{$goods_list.create_time|default=''}</td>
										                <td>{$goods_list.fail_explain|default=''}</td>
										            </tr>
										            {/volist}
										        </table>
										    </div>
										</div>
										{/if}
                                        {if condition="strpos('11,10,12',(string)$item.status) !== false"}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">退款审核记录：</label>
                                            <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <table width="80%" border="1" style="font-family: '微软雅黑';">
                                                    <tr align="center" style="font-size: 16px;">
                                                        <td>申请者</td>
                                                        <td>申请门店</td>
                                                        <td>审核状态</td>
                                                        <td>审核时间</td>
                                                        <td>失败原因</td>
                                                    </tr>
                                                    {volist name='refund_order_audit_records' id='goods_list'}
                                                    <tr align="center">
                                                        <td>{$goods_list.username|default=''}</td>
                                                        <td>{$goods_list.shop_title|default=''}</td>
                                                        <td>
                                                            {switch name="$goods_list.status"}
                                                            {case 11}审核成功{/case}
                                                            {case 12}审核失败{/case}
                                                            {/switch}
                                                        </td>
                                                        <td>{$goods_list.create_time|default=''}</td>
                                                        <td>{$goods_list.fail_explain|default=''}</td>
                                                    </tr>
                                                    {/volist}
                                                </table>
                                            </div>
                                        </div>
                                        {/if}
                                        {in name="item.status" value="10"}
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">退款状态：</label>
                                            <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <select name="status" class="form-control" style="width: 200px;float: left;" tabindex="-1" {in name='item.status' value='11,12'}disabled{/in}>
                                                <option value="11" {eq name='item.status' value='11'}selected{/eq}>申请退款成功</option>
                                                <option value="12" {eq name='item.status' value='12'}selected{/eq}>申请退款失败</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group tc">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">未退款理由：</label>
                                            <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <textarea type="text" placeholder="未退款理由,不填写留空" style="width: 500px;height: 100px;"
                                                          class="form-control col-md-7 col-xs-12" name="fail_explain">{$refund_find.message|default=''}</textarea>
                                                <div style="width:500px;clear: both">
                                                    <span style="font-size: 16px;color: red">注：只有在退款状态是退款失败的时候填写</span>
                                                </div>
                                            </div>
                                        </div>
                                        {/in}
                                </div>
                                {eq name="$item.t_type" value="1"}
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" style="text-align: right">是否隐藏会员提成：</label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <label class="radio_box">
                                            <input type="radio" name="type" id="status_1" class="cartradio"
                                                   value="1"
                                                   datatype="*"
                                                   nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                   {eq name='item.type|default="1"' value='1' }
                                                   checked
                                                   {/eq}
                                            >&nbsp;&nbsp;
                                            <label for="status_1"></label>
                                            <span>否</span>
                                            &nbsp;&nbsp;
                                        </label>
                                        <label class="radio_box">
                                            <input type="radio" name="type" id="status_2" class="cartradio"
                                                   value="2"
                                                   datatype="*"
                                                   nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                   {eq name='item.type|default=""' value='2' }
                                                   checked
                                                   {/eq}
                                            >&nbsp;&nbsp;
                                            <label for="status_2"></label>
                                            <span>是</span>
                                            &nbsp;&nbsp;
                                        </label>
                                    </div>
                                </div>
                                {/eq}
                                <div style="clear: both"></div>
                                {eq name="$item.t_type" value="1"}
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" style="text-align: right">只保留提成：</label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <label class="radio_box">
                                            <input type="radio" name="type2" id="status_3" class="cartradio"
                                                   value="1"
                                                   datatype="*"
                                                   nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                   {eq name='item.type|default="1"' value='1' }
                                                   checked
                                                   {/eq}
                                            >&nbsp;&nbsp;
                                            <label for="status_3"></label>
                                            <span>否</span>
                                            &nbsp;&nbsp;
                                        </label>
                                        <label class="radio_box">
                                            <input type="radio" name="type2" id="status_4" class="cartradio"
                                                   value="2"
                                                   datatype="*"
                                                   nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                   {eq name='item.type|default=""' value='2' }
                                                   checked
                                                   {/eq}
                                            >&nbsp;&nbsp;
                                            <label for="status_4"></label>
                                            <span>是</span>
                                            &nbsp;&nbsp;
                                        </label>
                                    </div>
                                </div>
                                {/eq}
                                <div class="keyia">

                                </div>
                                <div class="form-group">
                                    <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                        {if condition="in_array(session('role_id'),['11','12','13']) eq false"}
                                        {in name="$item.status" value="6,5,4"}
                                        {if condition="in_array(session('role_id'),['7,8,9,10']) !== false"}
                                        {else/}
                                        <button id="click1" type="button"  class="btn btn-primary" >确认记录</button>
                                        <button id="click2" onsubmit="return check();" type="submit" style="display: none" class="btn btn-danger">提交记录</button>
                                        <!--<button type="submit" class="btn btn-primary">提交记录</button>-->
                                        {/if}
                                        {/in}
                                        {if condition="$item.status eq 10 && $refund_button == true && strpos('7,8,9,10',(string)session('role_id')) !== false"}
                                        <button type="submit" class="btn btn-primary">退款申请</button>
                                        {/if}

                                        {in name="$item.status" value="50,1"}
                                        <a onClick="cancel({$item.member_id},{$item.id})" class="btn btn-primary">取消订单</a>
                                        {/in}
                                        <button type="button"  class="btn btn-danger" id="btnPrint">打印文本区域</button>
                                        {eq name="$item.t_type" value="1"}
                                        <button type="button"  class="btn btn-primary" id="parentIframe">打印表格订单</button>
                                        {/eq}
                                        {/if}
                                        <a type="reset"  class="btn btn-success " onClick="history.go(-1)">返回</a>
                                        {if condition="in_array($item.status,[6,5,4]) !== false"}
                                        <a type="button"  class="btn btn-primary" id="parentIframe23" href="{:url('GiftOrderTwo/index',['order_id' => $item.id])}">礼包二级订单</a>
                                        {/if}
                                        {if condition="$item.status eq 10 && session('role_id') eq 1"}
                                        <a onClick="tuikuan({$item.id},11)" class="btn btn-primary">管理员退款成功</a>
                                        <a onClick="tuikuan({$item.id},12)" type="submit" class="btn btn-primary">管理员退款失败</a>
                                        {/if}
                                    </div>
                                </div>

                                </form>

                                <script>
									var commitStatus = false;
									function check(){
										  if(commitStatus==false){
										//提交表单后，讲提交状态改为true
										  commitStatus = true;
										  return true;
										 }else{
										  return false;
									  }
									 }
									
									
									
                                    $('#click2').click(function () {
										$(this).setAttribute("disabled", true);
                                        $(this).hide();
										//alert('123456');
										
                                    });
                                </script>
                                <script>
                                    $(document).ready(function(){
                                    $('body').on('click','.click3',function () {
                                        $('#click2').hide();
//                                        alert('刘志言');
                                        $('#click1').show();
                                    });
                                    });

                                    $('#click1').click(function () {
//                                        alert(1);
                                        $(this).hide();
                                        $('#click2').show();
                                        var post_data = $("form").serialize();
                                        console.log(post_data);
                                        var b = {:session('auding_status')};
                                        console.log(b);
                                        if(b == 1){
                                            var shop_id = "{:session('shop_id')}";
                                            post_data = $.param({'shop_id': shop_id}) + '&' + post_data;
                                        }
                                        $.ajax( {
                                            type : 'POST',
                                            url : "{:url('index/gift_order/tijiao')}",
                                            data : post_data,
                                            success : function(msg) {
                                                console.log(msg);
                                                //alert(console.log(msg));
                                                var str = ' <div style="margin:20px;" class="form-group service_people">\n' +
                                                    ' <div class="" style="margin-top: 10px;">';+
                                                    '<td>服务门店</td><td>服务人员</td><td>服务分类</td><td>服务内容</td><td>创建时间</td>';
                                                $.each(msg['data'],function (k,v) {

                                                    str +='<table width="100%" border="1"><tr>';
                                                    str +='<td>'+v['shop_id']+'</td>';
                                                    str +='<td>'+v['assignor_id']+'</td>';
                                                    str +='<td>'+v['single_id']+'</td>';
                                                    str +='<td>'+v['assignor_content']+'</td>';
                                                    str +='<td>'+v['create_time']+'</td>';
                                                    str += '</tr></table>';

                                                });
                                                str += '</div></div>';
                                                str +='<style>td{padding:5px 15px; margin: 10px; font-size: 16px;} table{border-collapse: collapse;}</style>';
                                                layer.open({
                                                    type: 1,
                                                    skin: 'layui-layer-rim', //加上边框
                                                    area: ['800px', '440px'], //宽高
                                                    content: str
                                                });

                                                //$('.keyia').html(str);
                                            }
                                        });

                                    });




                                </script>
                                <div class="row">

                                    <div class="x_content col-md-12 col-sm-12 col-xs-12">
                                        <div class="form-group">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12"
                                                   style="text-align: right">会员付款码：</label>
                                            <div class="col-md-3 col-sm-6 col-xs-12">
                                                <input type="text" placeholder="线下扫码机获得" onchange="" {neq
                                                       name="$item.status" value="1" }disabled{/neq}
                                                class="form-control col-md-7 col-xs-12" name="auth_code"
                                                value="{$item.auth_code|default=''}" datatype="*" nullmsg="请填写运费金额"
                                                >
                                            </div>
                                            {eq name="$item.status" value="1"}
                                            <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                                <a type="reset" class="btn btn-success" onClick="mic_w_pay()">微信支付</a>
                                                <a type="reset" class="btn btn-success" onClick="mic_a_pay()">支付宝支付</a>
                                                <input type="hidden" name="order_amount" value="{$item.amount}"/>
                                                <input type="hidden" name="order_number" value="{$item.order_number}"/>

                                            </div>
                                            {/eq}
                                        </div>
                                    </div>
                                </div>



                            </div>
                        </div>


                    </div>
                    <!-- /page content -->

                </div>

            </div>
        </div>

        {include file="public_foot" /}
        <!-- validform -->
        <script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
        <script src="__STATIC__/js/layer.js"></script>
        <!--select-->
        <script src="__STATIC__/js/select/select2.full.min.js"></script>
        <script>
            $('#parentIframe').click(function(){
                layer.open({
                    type: 2,
                    area: ['100%', '100%'],
                    fixed: false, //不固定
                    maxmin: true,
                    content: 'http://lihai.xmdonkey.com/index.php/console/gift_order/update_dayin/id/'+"{:input('id')}"
                });
            });
            $('#parentIframe2').click(function(){
                layer.open({
                    type: 2,
                    area: ['100%', '100%'],
                    fixed: false, //不固定
                    maxmin: true,
                    content: 'http://lihai.xmdonkey.com/index.php/console/gift_order/update_dayin/id/'+"{:input('id')}"
                });
            });
            function mic_w_pay() {
                var auth_code = $("[name='auth_code']").val();
                var out_trade_no = $("[name='order_number']").val();
                var price = $("[name='order_amount']").val();
                if(!auth_code){
                    layer.msg('付款码不能为空');
                    return;
                }
                $.ajax({
                    type: "POST",
                    url: "{:url('mic/w_pay')}",
                    data: {auth_code:auth_code, out_trade_no:out_trade_no,price:price},
                    dataType: "json",
                    success: function(ret){
                        if(ret == true){
                            layer.msg('支付成功');
                            history.go(0);
                        }
                        else{
                            layer.msg('支付失败');
                        }
                    }

                });
            }

            function mic_a_pay() {

                var auth_code = $("[name='auth_code']").val();
                var out_trade_no = $("[name='order_number']").val();
                var price = $("[name='order_amount']").val();

                if(!auth_code){
                    layer.msg('付款码不能为空');
                    return;
                }

                $.ajax({
                    type: "POST",
                    url: "{:url('mic/a_pay')}",
                    data: {auth_code:auth_code, out_trade_no:out_trade_no,price:price},
                    dataType: "json",
                    success: function(ret){
                        if(ret == true){
                            layer.msg('支付成功');
                            history.go(0);
                        }
                        else{
                            layer.msg('支付失败');
                        }
                    }

                });
            }
            function del(id) {

                $.ajax({
                    type: "POST",
                    url: "{:url('console/gift_order/delete')}",
                    data: {id:id},
                    dataType: "json",
                    success: function(data){
                        //  $('#resText').empty();   //清空resText里面的所有内容
                        //var obj = JSON.parse(data);
                        if(data.code == 200){
                            layer.msg('删除1成功');
                            history.go(0);
                            //window.location.href = "{:url('index')}"
                        }
                        else{
                            layer.msg('取消失败');
                        }

                    }
                });
            }

            function tuikuan(order_id,status){

                $(function(){
var fail_explain = $('[name="fail_explain"]').val();

                    $.ajax({

                        type: "POST",

                        url: "{:url('index/order/tuikuan2')}",

                        data: {status:status, id:order_id,fail_explain:fail_explain},

                        dataType: "json",

                        success: function(data){

                            //  $('#resText').empty();   //清空resText里面的所有内容
                            //var obj = JSON.parse(data);
                            if(data.code == 200){
                                layer.msg(data.message);
                                history.go(0);
//                                window.location.href = "{:url('index')}"
                            }
                            else{
                                layer.msg(data.message);
                            }
                            //var html = '';

//                        $.each(data, function(commentIndex, comment){
//
//                            html += '<div class="comment"><h6>' + comment['username']
//
//                                + ':</h6><p class="para"' + comment['content']
//
//                                + '</p></div>';
//
//                        });
//
//                        $('#resText').html(html);

                        }

                    });

                    /// });

                });
            }

            function cancel(member_id,order_id){
                $(function(){
//
                    $.ajax({

                        type: "POST",

                        url: "{:url('index/order/cancel')}",

                        data: {member_id:member_id, order_id:order_id},

                        dataType: "json",

                        success: function(data){

                            //  $('#resText').empty();   //清空resText里面的所有内容
                            //var obj = JSON.parse(data);
                            if(data.code == 200){
                                layer.msg('订单取消成功');
                                history.go(0);
                                window.location.href = "{:url('index')}"
                            }
                            else{
                                layer.msg('取消失败');
                            }
                            //var html = '';

//                        $.each(data, function(commentIndex, comment){
//
//                            html += '<div class="comment"><h6>' + comment['username']
//
//                                + ':</h6><p class="para"' + comment['content']
//
//                                + '</p></div>';
//
//                        });
//
//                        $('#resText').html(html);

                        }

                    });

                    /// });

                });
            }
        </script>
        <script>

            // validform
            $(function () {

                $.Tipmsg.r = null;

                var showmsg = function (msg) {
                    //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
                    alert(msg);
                }

                // select2
                $(".select2_single").select2({
                    placeholder: "请选择快递公司",
                    allowClear: true
                });

                $(".select2_single2").select2({
                    placeholder: "请选择订单状态",
                    allowClear: true
                });

                $("#registerForm").Validform({
                    tiptype: function (msg) {
                        layer.msg(msg);
                    },
                    tipSweep: true
                });
            })

            function delThisTr(trobj)
            {

                //$('body').on('click','.click4',function () {
                $('#click2').hide();
//                alert('刘志言');
                $('#click1').show();
                trobj.parent().parent().remove();
            //});
            }



            function delThis(trobj,id)
            {
                if(confirm('确认删除？')){
                    $.ajax({
                        url : '{:url("service_order/shop_assignor_records")}',
                        data:{'id':id},
                        dataType:'html',
                        success:function(data){
                            data = JSON.parse(data);
                            console.log(data)
                            if(data.code == 200){
                                layer.msg('删除成功');
                                trobj.parent().parent().remove();
                            }else{
                                layer.msg(data.message);
                            }
                        }
                    });
                }
            }
            var assgioner = {$shop_assignor};
            console.log(assgioner);
            var s = [];

            s = '<tr><td><select name="status" class="form-control" tabindex="-1">' + ss
            s += '</select></td>';
            console.log(s);
            var ss = [];
            $.each(assgioner, function(k,v){
                ss += '<option value="'+v.id+'">'+v.name+'</option>';
            });
            //服务人员门店
            var gift_c;
            $.each({$now_gift_count}, function(k,v){ //礼包
                gift_c += '<option value="'+v.id+'">'+v.cat_name+'</option>';
            });
            var gift_shop_content;
            $.each({$service_people_price2}, function(k,v){ //服务人员提成
                gift_shop_content += '<option value="'+v.id+'">'+v.cat_name+'</option>';
            });
			var ssss = [];//岗位
			var post_list = {$post_list};
            $.each(post_list, function(k,v){
                ssss += '<option value="'+v.id+'">'+v.shop_title+'--'+v.title+'</option>';
            });
            $(".addNewTr").click(function(){

                var str = '<tr><td><select name="assignor_id[]" class="select2_single form-control" tabindex="-1"><option value=""></option>' + ss +
                    '</select></td>' +
                    '<td><input type="hidden" name="typea[]" value="1"><select name="single_id[]" onchange="single2(this.value,this)" class="select2_single form-control" tabindex="-1">' + gift_c +
                    '<td><select name="assignor_content[]" onchange="person_price(this.value,this)" class="select2_single form-control" tabindex="-1">' + gift_shop_content +
                    '<td><input name="assignor_price[]" readonly class="form-control" value="'+{$service_people_price2}[0]['person_price']+'" /></td>'+
                    '<td><a href="javascript:;" class="click3 click4" onclick="delThisTr($(this))">删除</a></td>'+
					'<td id="post_id"><select name="post_id[]" onchange="gangwei_pirce(this.value,this)" class="select2_single form-control" tabindex="-1"><option value=""></option>' + ssss +
					'</select></td>'+
					'<td><input name="pici[]" readonly class="form-control" value="'+{$pici}+'" /></td>'+
					'</tr>';
                str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                str +="<script>\n" +
                    "                                        $(\".select2_single\").select2({\n" +
                    "                                            placeholder: \"请选择分类\",\n" +
                    "                                            allowClear: true\n" +
                    "                                        });\n" +
                    "                                    <\/script>";

                $("#fieldtr").append(str);
            });

            $(".addNewTr_shop").click(function(){

                var str = '<tr><td><select name="assignor_id[]" class="select2_single form-control" tabindex="-1"><option value=""></option>' + ss +
                    '</select></td>' +
                    '<td><input type="hidden" name="typea[]" value="2"><select name="single_id[]" onchange="single2(this.value,this)" class="select2_single form-control" tabindex="-1"><option value="9999">门店购买人员</option>' +
                    '<td><select name="assignor_content[]" onchange="person_price(this.value,this)" class="select2_single form-control" tabindex="-1"><option value="9999">门店购买人员</option>' +
                    '<td><input name="assignor_price[]" readonly class="form-control" value="'+{$gift_shop_backstage}+'" /></td>'+
                    '<td><a href="javascript:;" class="click3 click4" onclick="delThisTr($(this))">删除</a></td>'+
					'<td ><select name="post_id[]" onchange="gangwei_pirce(this.value,this)" class="select2_single form-control" tabindex="-1"><option value=""></option>' + ssss +
					'</select></td>'+
					'<td><input name="pici[]" readonly class="form-control" value="'+{$pici}+'" /></td>'+
					'</tr>';
                str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                str +="<script>\n" +
                    "                                        $(\".select2_single\").select2({\n" +
                    "                                            placeholder: \"请选择分类\",\n" +
                    "                                            allowClear: true\n" +
                    "                                        });\n" +
                    "                                    <\/script>";
                $("#fieldtr_shop").append(str);
            });

            //    $(".addNewTr").click(function(){
            //        str =
            //            '<tr><td><input type="text" name="assignor_id[]"  /></td>' +
            //            '<td><input type="text" name="assignor_price[]"  /></td>' +
            //            '<td><input type="text" name="assignor_content[]" /></td>' +
            //            '<td><a href="javascript:;" onclick="delThisTr($(this))">删除</a></td></tr>';
            //        $("#fieldtr").append(str);
            //    });
            var sss = [];//总后台服务人员
            var shop_list = {$shop_list};
            $.each(shop_list, function(k,v){
                sss += '<option value="'+v.id+'">'+v.shop_title+'</option>';
            });
			var ssss = [];//岗位
			var post_list = {$post_list};
            $.each(post_list, function(k,v){
                ssss += '<option value="'+v.id+'">'+v.shop_title+'--'+v.title+'</option>';
            });
            $(".addNewTrshop").click(function(){

                var str = '<tr><td><select onchange="shop(this.value,this)" name="shop_id[]" class="select2_single form-control" tabindex="-1">' + sss+
                    '</select><td id="assignor_id"><select name="assignor_id[]" class="select2_single form-control" tabindex="-1"><option value=""></option>' + ss +
					'</select></td>'+
                    '<td id="server_people_price"><select name="single_id[]" onchange="single2(this.value,this)" class="select2_single form-control" tabindex="-1">' + gift_c +
                    '</select><input type="hidden" name="typea[]" value="1"></td>' +
                    '<td><select name="assignor_content[]" onchange="person_price(this.value,this)" class="select2_single form-control" tabindex="-1">' + gift_shop_content +
                    '<td><input name="assignor_price[]" readonly class="form-control" value="'+{$service_people_price2}[0]['person_price']+'" /></td>'+
                    '<td><a href="javascript:;" class="click3 click4" onclick="delThisTr($(this))">删除</a></td>'+
					'<td id="post_id"><select name="post_id[]" onchange="gangwei_pirce(this.value,this)" class="select2_single form-control" tabindex="-1"><option value=""></option>' + ssss +
					'</select></td>'+
					'<td><input name="pici[]" readonly class="form-control" value="'+{$pici}+'" /></td>'+
					'</tr>';
                str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                str +="<script>\n" +
                    "                                        $(\".select2_single\").select2({\n" +
                    "                                            placeholder: \"请选择分类\",\n" +
                    "                                            allowClear: true\n" +
                    "                                        });\n" +
                    "                                    <\/script>";
                $("#fieldtr").append(str);
            });

            //总台门店线下人员提成
            $(".addNewTrshop_backstage").click(function(){
                var str = '<tr><td><select onchange="shop_backstage(this.value,this)" name="shop_id[]" class="select2_single form-control" tabindex="-1">' + sss+
                    '</select><td id="assignor_id"><select name="assignor_id[]" class="select2_single form-control" tabindex="-1"><option value=""></option>' + ss +
                    '</select></td>' +
                    '<td id="server_people_price"><select name="single_id[]" onchange="single2(this.value,this)" class="select2_single form-control" tabindex="-1"><option value="9999">门店购买人员</option>'+
                    '</select><input type="hidden" name="typea[]" value="2"></td>' +
                    '<td><select name="assignor_content[]" onchange="person_price(this.value,this)" class="select2_single form-control" tabindex="-1"><option value="9999">门店购买人员</option>'+
                    '<td><input name="assignor_price[]" readonly class="form-control" value="'+{$gift_shop_backstage}+'" /></td>'+
                    '<td><a href="javascript:;" class="click3 click4" onclick="delThisTr($(this))">删除</a></td>'+
					'<td><select name="post_id[]" onchange="gangwei_pirce(this.value,this)" class="select2_single form-control" tabindex="-1"><option value=""></option>' + ssss +
					'</select></td>'+
					'<td><input name="pici[]" readonly class="form-control" value="'+{$pici}+'" /></td>'+
					'</tr>';
                str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                str +="<script>\n" +
                    "                                        $(\".select2_single\").select2({\n" +
                    "                                            placeholder: \"请选择分类\",\n" +
                    "                                            allowClear: true\n" +
                    "                                        });\n" +
                    "                                    <\/script>";
                $("#fieldtr_backstage").append(str);
            });
            function shop_backstage(id,t){
                var gift_id = {$item['gift_id']};

                //覆盖就分类 //人员
                $.ajax({
                    url : '{:url("shop_assignor")}',
                    data:{'shop_id':id},
                    dataType:'json',
                    success:function(data){
                        var str = [];
                        console.log(data);
                        str = '<input type="hidden" name="typea[]" value="2"><select name="assignor_id[]" class="select2_single form-control" tabindex="-1">';
                        $.each(data, function(k,v){
							str += '<option value=""></option>';
                            str += '<option value="'+v.id+'">'+v.name+'</option>';
                        });
                        str += '</select>';
                        str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                        str +="<script>\n" +
                            "                                        $(\".select2_single\").select2({\n" +
                            "                                            placeholder: \"请选择分类\",\n" +
                            "                                            allowClear: true\n" +
                            "                                        });\n" +
                            "                                    <\/script>";
                        $(t).parent().next().html(str);
                        console.log(str);
                    }
                });
                var order_id = "{:input('id')}";
                var t_type = "{$item['t_type']}";
                $.ajax({
                    url : '{:url("gift_shop_price")}',
                    data:{'shop_id':id,'gift_id':gift_id},
                    dataType:'json',
                    success:function(data){
                        $(t).parent().next().next().next().next().find('input').val(data);
                        console.log(str);
                    }
                });


            }

            function delThisTrr(trobj)
            {
                trobj.parent().parent().remove();
            }

            function shop(id,t){

                //覆盖就分类 //人员
                $.ajax({
                    url : '{:url("shop_assignor")}',
                    data:{'shop_id':id},
                    dataType:'json',
                    success:function(data){
                        var str = [];
                        console.log(data);
                        str = '<input type="hidden" name="typea[]" value="1"><select name="assignor_id[]" class="select2_single form-control" tabindex="-1">';
                        $.each(data, function(k,v){
							str += '<option value=""></option>';
                            str += '<option value="'+v.id+'">'+v.name+'</option>';
                        });
                        str += '</select>';
                        str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                        str +="<script>\n" +
                            "                                        $(\".select2_single\").select2({\n" +
                            "                                            placeholder: \"请选择分类\",\n" +
                            "                                            allowClear: true\n" +
                            "                                        });\n" +
                            "                                    <\/script>";
                        $(t).parent().next().html(str);
                        console.log(str);
                    }
                });
                var order_id = "{:input('id')}";
                var t_type = "{$item['t_type']}";

                //覆盖旧的服务金额
                $.ajax({ //当前礼包一级类
                    url : '{:url("now_gift_count")}',
                    data:{'shop_id':id,'order_id':order_id,'t_type':t_type},

                    success:function(data){
                        console.log('console:'+data);
                        var str = [];
                        console.log('console:'+data);
                        str = '<select name="single_id[]" onchange="single2(this.value,this)" class="select2_single form-control" tabindex="-1">';
                        $.each(data.one_level, function(k,v){
                            str += '<option value="'+v.id+'">'+v.cat_name+'</option>';
                        });
                        str += '</select>';
                        str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                        str +="<script>\n" +
                            "                                        $(\".select2_single\").select2({\n" +
                            "                                            placeholder: \"请选择分类\",\n" +
                            "                                            allowClear: true\n" +
                            "                                        });\n" +
                            "                                    <\/script>";
                        $(t).parent().next().next().html(str);
                        var assignor_content = '<select name="assignor_content[]" onchange="person_price(this.value,this)" class="select2_single form-control" tabindex="-1">';
                        $.each(data.two_level, function(k,v){
                            assignor_content += '<option value="'+v.id+'">'+v.cat_name+'</option>';
                        });
                        assignor_content += '</select>';
                        assignor_content += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                        assignor_content +="<script>\n" +
                            "                                        $(\".select2_single\").select2({\n" +
                            "                                            placeholder: \"请选择分类\",\n" +
                            "                                            allowClear: true\n" +
                            "                                        });\n" +
                            "                                    <\/script>";
                        $(t).parent().next().next().next().html(assignor_content);
                        var assignor_price = '<input name="assignor_price[]" readonly class="form-control" value="'+data['two_level'][0]['person_price']+'" />';
                        $(t).parent().next().next().next().next().html(assignor_price);

                    }
                });

            }
            function single2(id,t) { //获得2级类以及价格
                var shop_id = 0;
                var order_id = {$item.id};
                var t_type = "{$item.t_type}";
                if({:session('auding_status')} == 1){
                    shop_id = "{:session('shop_id')}";
                }else{
                    shop_id = $(t).parent().prev().prev().find('select').val();
                }
                $.ajax({
                    url : '{:url("single/ajax2")}',
                    data:{'id':id,'shop_id':shop_id,'order_id':order_id,'t_type':t_type},
                    dataType:'json',
                    success:function(data){
                        var str = [];
                        console.log(data);
                        str = '<select name="assignor_content[]" onchange="person_price(this.value,this)" class="select2_single form-control" tabindex="-1">';
                        $.each(data, function(k,v){
                            str += '<option value="'+v.id+'">'+v.cat_name+'</option>';
                        });
                        str += '</select>';
                        str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                        str +="<script>\n" +
                            "                                        $(\".select2_single\").select2({\n" +
                            "                                            placeholder: \"请选择分类\",\n" +
                            "                                            allowClear: true\n" +
                            "                                        });\n" +
                            "                                    <\/script>";
                        $(t).parent().next().html(str);
                        var person_price = [];
                        person_price = '<td><input name="assignor_price[]" readonly class="form-control" value="'+data[0]['person_price']+'" /></td>';
                        $(t).parent().next().next().html(person_price);
                        console.log(person_price);
                    }
                });
            }

            function person_price(id,t) { //二级类获得字的价格
                var order_id = {$item.id};
                if({:session('auding_status')} == 1){
                    var shop_id = "{:session('shop_id')}";
                }else{
                    var shop_id = $(t).parent().prev().prev().prev().find('select').val();
                }
                $.ajax({
                    url : '{:url("single/ajax4")}',
                    data:{'id':id,'shop_id':shop_id,'order_id':order_id},
                    dataType:'json',
                    success:function(data){
                        console.log(data);
                        var person_price = [];
                        person_price = '<td><input name="assignor_price[]" readonly class="form-control" value="'+data+'" /></td>';
                        $(t).parent().next().html(person_price);
                    }
                });
            }
			
			function gangwei_pirce(id,t) { //二级类获得字的价格
                 var order_id = {$item.id};
				 var assignor_content =$(t).parent().prev().prev().prev().find('select').val();
				 if({:session('auding_status')} == 1){
                    var shop_id = "{:session('shop_id')}";
                }else{
                    var shop_id = $(t).parent().prev().prev().prev().prev().prev().prev().find('select').val();
                }
				/*$.ajax({
                    url : '{:url("single/ajax4")}',
                    data:{'id':assignor_content,'shop_id':shop_id,'order_id':order_id},
                    dataType:'json',
                    success:function(data){
                        console.log(data);
                       $(t).parent().prev().prev().find('input').val(data);
                       
                    }
                });*/
				
				var yuan_ticheng =$(t).parent().prev().prev().find('input').val();
				var type = '1';
				
				$.ajax({
                    url : '{:url("single/ajax5")}',
                    data:{'id':id,'shop_id':shop_id,'order_id':order_id,'yuan_ticheng':yuan_ticheng,'assignor_content':assignor_content,'type':type},
                    dataType:'json',
                    success:function(data){
                        console.log(data);
                        var person_price = [];
                        person_price = '<td><input name="assignor_price[]" readonly class="form-control" value="'+data+'" /></td>';
                        $(t).parent().prev().prev().html(person_price);
						$(t).parent().prev().prev().find('input').val(data);
                    }
                });
				
            }
			
			
        </script>
        <script src="/jquery.PrintArea.js" type="text/JavaScript" language="javascript"></script>
        <script>
            $('#status_2').click(function () {

                $('.service_people').hide();

            });
            $('#status_1').click(function () {

                $('.service_people').show();

            });
            $("#btnPrint").click(function(){
                $("#printArea").printArea();
            });
            $("#btnPrintFull").click(function(){
                $("body").printArea();
            });

            $('#status_4').click(function () { //是隐藏提成
                $('#service_people').show();
                $('.tc').hide();
            });
            $('#status_3').click(function () {
                $('#service_people').show();
                $('.tc').show();
            });
        </script>
        <script>
            //分类
            var category = {$category};
            var cat_list = '<option value="0">'+'&nbsp&nbsp'.repeat(1)+'|--全部分类</option>';
            var repeat = '-';
            $.each(category, function(k,v){
                cat_list += '<option value="'+v.id+'">'+'&nbsp&nbsp'.repeat(v.count)+'|--'+v.title+'</option>';
            });
            //规格商品 门店或全部
            var spec_attr_list = {$spec_attr_list};
            var spec_list = [];
            // console.log(spec_attr_list);
            $.each(spec_attr_list, function(k,v){
                spec_list += '<option value="'+v.id+'">'+'&nbsp&nbsp'.repeat(v.count)+'|--'+v.shop_title+'-'+v.title+'-'+v.attribute+'-'+v.inventory+'</option>';
            });
            // console.log(spec_list);
            $(".addNewTrgoods").click(function(){
                var str =
                    '<tr>' +
                    '<td><select name="cat_id[]" onchange="goods_list(this.value,this)" class="select2_single form-control" tabindex="-1">' + cat_list +
                    '</select></td>' +
                    '<td><select name="spec_id[]" id="spec" class="select2_single form-control" tabindex="-1">' + spec_list +
                    '</select></td>' +
                    '<td><input type="text" name="number[]" oninput="inventory(this,this.value)"  /></td>'+
                    '<td><input type="text" value="{:date('Y-m-d H:i:s',time())}" /></td>' +
                '<td><a href="javascript:;" class="click3 click4" onclick="delThisTrgoods($(this))">删除</a></td>' +
                '</tr>';
                str += '<script src="__STATIC__\/js\/select\/select2.full.min.js"><\/script>';
                str +="<script>\n" +
                    "                                        $(\".select2_single\").select2({\n" +
                    "                                            placeholder: \"请选择分类\",\n" +
                    "                                            allowClear: true\n" +
                    "                                        });\n" +
                    "                                    <\/script>";
                $("#fieldtrgoods").append(str);
            });
            function delThisTrgoods(trobj)
            {

                trobj.parent().parent().remove();
            }
            function delThigoods(trobj,id) {
                if(confirm('确认删除？')){
                    $.ajax({
                        url : '{:url("service_order_goods")}',
                        data:{'id':id},
                        dataType:'html',
                        success:function(data){
                            data = JSON.parse(data);
                            console.log(data)
                            if(data.code == 200){
                                layer.msg('删除成功');
                                trobj.parent().parent().remove();
                            }else{
                                layer.msg(data.message);
                            }
                        }
                    });
                }
            }
            function inventory(t,number) {
                console.log($(this));
                var spec_id = $(t).parent().prev().find('select').val();

                $.ajax({
                    url : '{:url("service_order/inventory")}',
                    data:{'number':number,'spec_id':spec_id},
                    dataType:'json',
                    success:function(data){
                        if(data.code != 200){
                            layer.msg(data.message);
                            return false;
                        }
                    }
                });
//        $('name=["spec_id"]').val();
//        if(number > inventory){
//            layer.msg('商品数量大于库存数量');
//        }
            }
            function goods_list(id,t){
                $.ajax({
                    url : '{:url("service_order/goods_list")}',
                    data:{'cat_id':id},
                    dataType:'json',
                    success:function(data){
                        var str = [];
                        console.log(data);
                        str = '<select name="spec_id[]" class="form-control" tabindex="-1">';
                        $.each(data, function(k,v){
                            str += '<option value="'+v.id+'">'+'&nbsp&nbsp'.repeat(v.count)+'|--'+v.shop_title+'-'+v.title+'-'+v.attribute+'-'+v.inventory+'</option>';
                        });
                        str += '</select>';
                        $(t).parent().next().html(str);
//                console.log(str);
                    }
                });
            }
        </script>
</body>

</html>
